Skip to content

SEP-1521: Extract a shared backup response base for the three backup apps - #1127

Merged
yyyyyyyan merged 13 commits into
mainfrom
SEP-1521
Jul 21, 2026
Merged

SEP-1521: Extract a shared backup response base for the three backup apps#1127
yyyyyyyan merged 13 commits into
mainfrom
SEP-1521

Conversation

@peter-o-addo

@peter-o-addo peter-o-addo commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Extract a shared backup-family BackupTaskBase (hostname only) into app/sep/apps/backup_responses.py, repoint the three backup apps at it, and rename mysql_backups' BackupResponse to BackupTaskResponse so all backup apps share the same response naming.

  • app/sep/apps/backup_responses.py : new shared BackupTaskBase(BaseTaskResponse) carrying hostname: str | None = None
  • app/sep/apps/backup_mongo/models.py, app/sep/apps/backup_pg/models.py : removed local BackupTaskBase; import shared base; BackupTaskResponse / detail models unchanged
  • app/sep/apps/mysql_backups/models.py : import shared base; renamed BackupResponseBackupTaskResponse; moved backup_type: BackupType | None onto the child (hostname inherited from shared base)
  • app/sep/apps/mysql_backups/app.py, app/sep/apps/mysql_backups/deps.py : updated imports, response_model, builder return type, and build_default_task_response call to BackupTaskResponse
  • tests/app/sep/snapshots/openapi/mysql_backups.json, tests/app/sep/snapshots/openapi/backup_mongo.json, tests/app/sep/snapshots/openapi/backup_pg.json : regenerated OpenAPI goldens for BackupResponseBackupTaskResponse rename and updated PaginatedResponse[BackupTaskResponse] disambiguation suffixes
  • frontend/packages/api/specs/sep.json, frontend/packages/api/src/generated/sep.ts : regenerated frontend spec and TS client to match the mysql_backups rename and pagination schema key changes
  • tests/app/sep/apps/mysql_backups/test_models.py : renamed BackupResponse references and test class to BackupTaskResponse

Tested

  • For each of MySQL, PostgreSQL, and MongoDB backups, open the task list and one task detail page and confirm the Type and Executor host columns render with no 404/500 responses or console errors.

Checklist

  • New/modified functions have type hints and rST docstrings
  • New tests added for new features or bug fixes
  • All tests pass locally (make test)
  • Pre-commit hooks pass (make run-pre-commit)
  • Database migrations generated if models changed (make makemigrations)
  • User-facing changes documented (README, inline help, UI text)
  • Configuration changes documented with examples
  • Changelog fragment added under changelog.d/ if the change is user-facing (make changelog-add), or confirmed N/A (internal-only change, or a same-release-cycle fix for an unreleased sibling ticket)

@peter-o-addo
peter-o-addo marked this pull request as ready for review July 15, 2026 08:52
Copilot AI review requested due to automatic review settings July 15, 2026 08:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes the “backup-family” task response surface across backup_mongo, backup_pg, and mysql_backups by extracting a shared response base and aligning response model naming, then regenerating OpenAPI snapshots and the frontend API client to match the updated schema.

Changes:

  • Introduce a shared BackupTaskBase(BaseTaskResponse) carrying hostname and reuse it across the three backup apps.
  • Rename mysql_backups BackupResponseBackupTaskResponse and update route/dep/test references accordingly.
  • Regenerate OpenAPI golden snapshots and the frontend OpenAPI spec + generated TypeScript client for the new component names.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
app/sep/apps/backup_responses.py Adds shared BackupTaskBase used by all backup-family apps.
app/sep/apps/backup_mongo/models.py Switches to importing the shared BackupTaskBase.
app/sep/apps/backup_pg/models.py Switches to importing the shared BackupTaskBase.
app/sep/apps/mysql_backups/models.py Switches to shared base and renames response model to BackupTaskResponse.
app/sep/apps/mysql_backups/deps.py Updates response builder return type and construction to BackupTaskResponse.
app/sep/apps/mysql_backups/app.py Updates app registration response_model to BackupTaskResponse.
tests/app/sep/apps/mysql_backups/test_models.py Renames tests and usages to BackupTaskResponse.
tests/app/sep/snapshots/openapi/mysql_backups.json Updates OpenAPI snapshot for renamed response model and paginated schema keys.
tests/app/sep/snapshots/openapi/backup_mongo.json Updates OpenAPI snapshot for new paginated schema key suffix.
tests/app/sep/snapshots/openapi/backup_pg.json Updates OpenAPI snapshot for new paginated schema key suffix.
frontend/packages/api/specs/sep.json Regenerates frontend OpenAPI spec to match backend response model rename.
frontend/packages/api/src/generated/sep.ts Regenerates TypeScript client/types to match updated OpenAPI components.

Comment thread app/sep/apps/shared/backups/responses.py
Comment thread tests/app/sep/apps/mysql_backups/test_models.py Outdated
@peter-o-addo peter-o-addo added the qa in progress Someone is currently testing this PR - do not merge it label Jul 15, 2026
@peter-o-addo

Copy link
Copy Markdown
Contributor Author
image image image image

@peter-o-addo peter-o-addo added qa passed Tests for this PR are completed and successful. and removed qa in progress Someone is currently testing this PR - do not merge it labels Jul 15, 2026
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  app/sep
  inventory.py
  app/sep/apps/backup_mongo
  models.py
  app/sep/apps/backup_pg
  models.py
  app/sep/apps/mysql_backups
  app.py
  deps.py
  models.py
  app/sep/apps/mysql_backups/restore
  deps.py
  app/sep/apps/shared/backups
  responses.py
  app/sep/sync/syncers/mysql
  syncer.py
Project Total  

This report was generated by python-coverage-comment-action

@yyyyyyyan yyyyyyyan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peter-o-addo — clean, tightly-scoped extraction. The shared BackupTaskBase kills the hostname triplication exactly as the ticket asks, living alongside framework so that layer stays domain-neutral; backup_type stays optional on the mysql child (confirmed in the regenerated snapshot — it's nullable and not in required); and the rename is complete, with no lingering BackupResponse references left in app/, tests/, or frontend/. test_exposes_inherited_task_response_surface still genuinely exercises the repointed inheritance.

One thing worth noting on scope: the AC said the backup_mongo / backup_pg snapshots would be unchanged, but both moved (PaginatedResponse_BackupTaskResponse___1→___2 and ___2→___3). That's correct and unavoidable — renaming mysql's class to BackupTaskResponse makes it a three-way name collision, so FastAPI mangles all three with module-qualified keys and renumbers the order-dependent suffixes. Regenerating those snapshots was the right call; the AC just under-counted the blast radius.

A few optional docstring nits, posted inline as one-click suggestions — all cases of a :type:/:rtype: line restating an annotation the signature already carries (backup_responses.py:33, mysql_backups/models.py:651, deps.py:168).

On the two open Copilot threads:

  • backup_responses.py:26 — the suggested change (import from framework.responses) won't actually avoid the framework/__init__ side effects: Python runs a package's __init__ for any submodule import, so importing framework.responses still executes all of framework/__init__'s re-exports (I confirmed this directly). The real inaccuracy is the module docstring's claim that the layer is shared "without importing framework.__init__ and unrelated SQLModel tables into scope" — that's the part worth softening, not the import line.
  • test_models.py:117 — agree; the "Tests for …" opener reads as a noun phrase, so an imperative verb (e.g. "Cover …") fits the convention.

Nothing blocking — all findings are cosmetic. Approving.

Comment thread app/sep/apps/backup_responses.py Outdated
Comment thread app/sep/apps/mysql_backups/models.py Outdated
Comment thread app/sep/apps/mysql_backups/deps.py Outdated
Comment thread app/sep/apps/shared/backups/responses.py
@peter-o-addo
peter-o-addo requested a review from yyyyyyyan July 20, 2026 08:53
peter-o-addo and others added 2 commits July 21, 2026 10:38
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@yyyyyyyan yyyyyyyan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peter-o-addo — all four points from the last round are addressed: BackupTaskBase now lives at app/sep/apps/shared/backups/responses.py alongside columns.py / edit_form.py, it is exported through shared/backups/__init__.py, the three consumers import it from the submodule (matching how BACKUP_TYPE_COLUMN and parse_server_list_config are already imported), and the three redundant :type: / :rtype: directives are gone. No new issues in the fix commits.

Minor — stale path in the PR Summary. The Summary still lists app/sep/apps/backup_responses.py : new shared BackupTaskBase(BaseTaskResponse); that module was removed by the move. Worth updating the bullet to the new path before merge so the description matches the diff.

LGTM.

@yyyyyyyan
yyyyyyyan enabled auto-merge (squash) July 21, 2026 18:07
@yyyyyyyan
yyyyyyyan merged commit ad85d7b into main Jul 21, 2026
20 checks passed
@yyyyyyyan
yyyyyyyan deleted the SEP-1521 branch July 21, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend python qa passed Tests for this PR are completed and successful.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants